#include <iostream>
#include <cstring>
using namespace std;

class File
{
public:
    File(const char* name)
    {
        fp = fopen(name,"w");
        if(fp == NULL)
        {
            cout << "文件打开失败" << endl;
        }
    }
    void write(const char* buf)
    {
        fwrite(buf,1,strlen(buf),fp);
    }
private:
    FILE *fp;
};

int main()
{
    File f1("test.txt");
    f1.write("hello world");
    return 0;
}